package hn.sigit.model.hnd.administrative;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

@Entity
@org.hibernate.annotations.Proxy(lazy=false)
@Table(name="HND_TransactionLog", schema="hnd_administrative")
@Inheritance(strategy=InheritanceType.JOINED)
public class HND_TransactionLog implements Serializable {
	private static final long serialVersionUID = 1648444850358012746L;
	
	private Long id;
	private Date dateActivity;
	private Date dateClaimed;
	private HND_ActivityType activity;
	private String transitionMessage;
	
	private HND_User claimingUser;
	private HND_Transaction transaction;
	
	
	@Id
	@Column(name="ID", nullable=false)
	@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="hnd_transactionlog_id_gen")
	@SequenceGenerator(name="hnd_transactionlog_id_gen", sequenceName="hnd_transactionlog_id_seq", allocationSize=1)
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	
	@Column(name="DateActivity", nullable=false)
	public Date getDateActivity() {
		return dateActivity;
	}
	public void setDateActivity(Date dateActivity) {
		this.dateActivity = dateActivity;
	}
	
	@Column(name="DateClaimed", nullable=true)
	public Date getDateClaimed() {
		return dateClaimed;
	}
	public void setDateClaimed(Date dateClaimed) {
		this.dateClaimed = dateClaimed;
	}
	
	@Column(name="Activity", nullable=false)
	@Enumerated(EnumType.STRING)
	public HND_ActivityType getActivity() {
		return activity;
	}
	public void setActivity(HND_ActivityType activity) {
		this.activity = activity;
	}
	
	@Column(name="TransitionMessage", nullable=true)
	public String getTransitionMessage() {
		return transitionMessage;
	}
	public void setTransitionMessage(String transitionMessage) {
		this.transitionMessage = transitionMessage;
	}
	
	@ManyToOne(targetEntity=HND_User.class, fetch=FetchType.LAZY, optional=true)
	@org.hibernate.annotations.Cascade({org.hibernate.annotations.CascadeType.LOCK})
	@JoinColumns({ @JoinColumn(name="HND_UserID", referencedColumnName="ID") })	
	@org.hibernate.annotations.LazyToOne(value=org.hibernate.annotations.LazyToOneOption.NO_PROXY)
	public HND_User getClaimingUser() {
		return claimingUser;
	}
	public void setClaimingUser(HND_User claimingUser) {
		this.claimingUser = claimingUser;
	}
	
	@ManyToOne(targetEntity=HND_Transaction.class, fetch=FetchType.LAZY, optional=false)
	@org.hibernate.annotations.Cascade({org.hibernate.annotations.CascadeType.LOCK})
	@JoinColumns({ @JoinColumn(name="HND_TransactionID", referencedColumnName="ID") })	
	@org.hibernate.annotations.LazyToOne(value=org.hibernate.annotations.LazyToOneOption.NO_PROXY)
	public HND_Transaction getTransaction() {
		return transaction;
	}
	public void setTransaction(HND_Transaction transaction) {
		this.transaction = transaction;
	}
}
